import Cookies from 'js-cookie'

const TokenKey = 'token'
const menuKey = 'menu'
const avatarKey = 'avatar'
const unitOptionsKey = 'unitOptions'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getAvatar() {
  return Cookies.get(avatarKey)
}

export function setAvatar(avatar) {
  return Cookies.set(avatarKey, avatar)
}

export function removeAvatar() {
  return Cookies.remove(avatarKey)
}

export function getMenus() {
  return JSON.parse(localStorage.getItem(menuKey)) || []
}

export function setMenus(menu) {
  return localStorage.setItem(menuKey, JSON.stringify(menu))
}

export function removeMenus() {
  return localStorage.removeItem(menuKey)
}

export function getUnitOptions() {
  return JSON.parse(localStorage.getItem(unitOptionsKey)) || []
}

export function setUnitOptions(unitOptions) {
  return localStorage.setItem(unitOptionsKey, JSON.stringify(unitOptions))
}

export function removeUnitOptions() {
  return localStorage.removeItem(unitOptionsKey)
}
